import com.lbi.framework.mvc.collection.Selectable;

import asunit.framework.TestCase;
import com.lbi.framework.mvc.collection.ISelectable;

/**
 * @author michaelforrest
 */
class framework.collection.SelectableTest extends TestCase {
	private var className : String = "SelectableTest";
	private var selectable : Selectable;
	
	public function SelectableTest(testMethod : String) {
		super(testMethod);
	}
	private function setUp() :Void{
		selectable = new Selectable();
	}
	private function tearDown() :Void{
		delete selectable;
	}
	private function testEvents() :Void{
		var selected_fired : Boolean = false;
		var deselected_fired : Boolean = false;
		selectable.addEventListener(Selectable.SELECTED, function() {
			selected_fired = true;
		});
		selectable.addEventListener(Selectable.DESELECTED, function() {
			deselected_fired = true;
		});
		selectable.select();
		assertTrue("should have fired 'selected'",selected_fired);
		selected_fired = false;
		selectable.select(); 
		assertFalse("should not fire again if already selected",selected_fired);
		selectable.deselect();
		assertTrue(deselected_fired);
	}
	private function testStateStuff() :Void{
		var default_state : Boolean = selectable.isSelected();
		assertEquals(false, default_state);
		selectable.select();
		assertEquals(true, selectable.isSelected());
	}
}